package com.simulated.communication.config;

import com.simulated.communication.networkprocessing.WebSocketServer;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

/**
 * @Author Markburt
 * @Description : 同步加载类 启动WebSocketServer
 * @DATE: 2020/5/6
 * @TIME: 上午 09:20
 * @YEAR: 2020
 * @Version :
 **/
@Component
public class NettyBooter implements ApplicationListener<ContextRefreshedEvent> {

    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        //事件获得上下文对象化后启动服务器
        if(contextRefreshedEvent.getApplicationContext().getParent() == null){
            WebSocketServer.getInstance().start();
        }
    }
}
